home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!smryan
- From: smryan@netcom.com (@#$%!?!)
- Subject: Re: saving system()'s output to a C variable?
- Message-ID: <smryanDpuDMI.Cyq@netcom.com>
- Organization: The Programmer formerly known as S M Ryan
- X-Newsreader: TIN [version 1.2 PL1]
- References: <96104.233554U61441@uicvm.uic.edu>
- Date: Sun, 14 Apr 1996 07:47:06 GMT
- Sender: smryan@netcom13.netcom.com
-
- : Is it possible to save the output of the system() command to
- : a C variable? For example, when I have the line system("date")
- : in my C program, I want the output of this command to go to a
- : C variable (e.g. char array) instead of going on the stdout.
- : Please send me email at swaheed@uic.edu
-
- If your system has pipes or the like, you can use popen/pclose.
- Otherwise, just the save the output to a file and then read the
- file.
-
- system("date >xx");
- f = fopen("xx","r");
- fgets(array,size,f);
- fclose(f);
- --
- The Queen, amused, in quiet power, | smryan@netcom.com PO Box 1563
- will draw the son to darkenned bower. | Cupertino, California
- Her face is fair, her fragrance rare, | (xxx)xxx-xxxx 95015
- with woven webs for wayward flower. | I don't use no smileys
-